<?php
/**
 * 文件上传接口
 */
namespace app\admins\controller\sys;
use \app\admins\controller\Base;
class Upload extends Base{
    
    /**
     * 上传图片
     */
    public function image($width=0,$height=0,$imgx=0,$imgy=0,$rotate=0){        
        try{            
            $type = input('type','default');
            $Upload = new \logic\sys\Upload();
            $result = $Upload->images($type,$width,$height,$imgx,$imgy,$rotate);            
            if( $result['ret'] ){
                $data = json_encode(['code'=> 1, 'msg'=>'上传成功','data'=> $result['filehttp']]);
               // $this->success('上传成功','',$result['filehttp']);
            }else{
                $data = json_encode(['code'=> 0, 'msg'=>'上传文件失败:'.$result['data'] ]);
               // $this->error('上传文件失败','',$result['data']);
            }            
        }catch( \think\Exception $e){
            //$this->error('上传文件失败','',$e->getMessage());
            $data = json_encode(['code'=> 0, 'msg'=>'上传文件失败:'.$e->getMessage()]);
        }
        exit($data);
    }
    
    
}